package cn.toprog.viewer.component;

import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.input.ContextMenuEvent;

/**
 * 项目名称: TaoImagerViewer
 * 创建时间: 2021/4/14 17:39
 * 作者姓名: xiaolei
 */

public class PopupMenu extends ContextMenu {
    public PopupMenu(Node pane) {
        pane.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
            @Override
            public void handle(ContextMenuEvent event) {
                if(event.getPickResult().getIntersectedNode() == pane) {
                    hide();
                    show(pane, event.getScreenX(), event.getScreenY());
                }
            }
        });
    }
}
